package com.sfpay.coreplatform.account.service.inner.impl;

import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.sfpay.coreplatform.account.service.inner.IAsyncAccountService;
import com.sfpay.coreplatform.account.service.inner.IGetAsyncAccounts;
import com.sfpay.pubcenter.domain.BaseParam;

/**
 * 
 * 
 * 类说明：判断异步记账账户
 * 
 * 
 * <p>
 * 详细描述：判断账户是否支持异步记账
 * 
 * 
 * @author sfhq104
 * 
 *         CreateDate: 2012-4-10
 */

@Service
public class AsyncAccountServiceImpl implements IAsyncAccountService {

	@Resource
	private IGetAsyncAccounts getAsyncAccount;
	
	private static Logger logger = LoggerFactory.getLogger(AsyncAccountServiceImpl.class);
	
	/* (non-Javadoc)
	 * @see com.sfpay.account.service.IAsyncAccount#isAsyncAccount(java.lang.Long)
	 */
	@Override
	public boolean isAsyncAccount(Long accountId) {
		try{
			Map<String,BaseParam> acctCaches= getAsyncAccount.getAsyncAccountsFromConfigCenter();
			logger.info(accountId+":"+acctCaches.toString());
			BaseParam bp = acctCaches.get(accountId.toString());
			if(bp == null)
			    return false;
			else
				return "1".equals( bp.getParamValue() );
		}catch(Exception ex){
			logger.error("AsyncAccountImpl_isAsyncAccount_exception:",ex);
			return false;
		}
		
	}

}
